<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue2.js"></script>
    <!--    引入vue的路由-->
    <script src="../js/vue-router.js"></script>
</head>
<body>

<div id="app">
    <router-view></router-view>
</div>

<script>

    // 智能穿戴
    let smartwear = {
        template: `
        <div style="width: 600px;height: 400px;border: 1px solid green">
            <h3>智能穿戴</h3>
            <router-link to="/headset" tag="button">耳机</router-link>
            <router-link to="/wear"    tag="button">穿戴</router-link>
            <hr>
            <router-view></router-view>
        </div>
      `
    }

    // 耳机
    let headset = {
        template: `
        <div style="width: 200px;height: 200px;border: 1px solid red">
            <h3>耳机</h3>
        </div>
      `
    }

    // 穿戴
    let wear = {
        template: `
        <div style="width: 200px;height: 200px;border: 1px solid blue">
            <h3>穿戴</h3>
        </div>
      `
    }


    const routes = [
        {
            path:'/',
            component:smartwear,
            children:[
                {
                    path:'/headset',
                    component:headset
                },
                {
                    path:'/wear',
                    component:wear
                }
            ]
        }
    ]


    let router = new VueRouter({
        routes
    })

    let vm = new Vue({
        el: '#app',
        data: {},
        methods: {},
        router
    })
</script>
</body>
</html>